package io;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

import org.junit.Test;

public class ReaderWriterDemo {
	@Test
	public void write() {
		try (FileWriter writer = new FileWriter("a.txt",true)){
			writer.write("hello");
			writer.flush();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	@Test
	public void read() {
		try(FileReader reader = new FileReader("a.txt")){
			
			char[] content = new char[20];
			reader.read(content);
			
			System.out.println(content);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
